<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!-- 加入 TestServletContextListener类，引用方法-->
<%@page import="com.listener.TestServletContextListener"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
     <title>Session监听器监听</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
  </head>
  
  <body>
           一访问JSP页面，HttpSession就创建了，创建好的Session的Id是：${pageContext.session.id}
           
       <%
           //往session域对象中添加属性
           session.setAttribute("aa", "bb");
          //替换session域对象中aa属性的值
           session.setAttribute("aa", "xx");
           //移除session域对象中aa属性
           session.removeAttribute("adminInSession");
       %>  
       
       <% 
        //将javabean对象绑定到Session中
        session.setAttribute("bean",new TestServletContextListener("孤傲苍狼"));
        //从Session中删除javabean对象
        //session.removeAttribute("bean");
       %>          
                   
  </body>
</html>
